﻿@model Accounting.DataAccess.Category
@{
    ViewBag.Title = "Edit";
}
<h2>
    Edit Category</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Category</legend>
        @Html.HiddenFor(model => model.Id)
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <div>
            <p>
                @Html.ActionLink("Create Sub Category", "CreateSub", new { categoryId = Model.Id })
            </p>
            <table>
                <tr>
                    <th>
                        Sub Category
                    </th>
                    <th>
                    </th>
                </tr>
                @foreach (var item in Model.SubCategories)
                {
                    <tr>
                        <td>
                            @Html.ActionLink(item.Name, "EditSub", new { id = item.Id })
                        </td>
                        <td>
                            @Html.ActionLink("Delete", "DeleteSub", new { id = item.Id })
                        </td>
                    </tr>
                }
            </table>
        </div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
